package com.ymx.darling.datasource.routing;

import com.ymx.darling.datasource.routing.dataSourceConfig.ConfigType;
import com.ymx.darling.datasource.routing.dataSourceConfig.DruidConfig;
import com.ymx.darling.datasource.routing.dataSourceConfig.HikariConfig;
import com.ymx.darling.dialect.Dialect;

import java.util.Properties;

public class DataSourceProperties extends org.springframework.boot.autoconfigure.jdbc.DataSourceProperties {
    /**
     * 配置的类型
     */
    private ConfigType configType;

    /**
     * hikari 数据连接池配置
     */
    private HikariConfig hikari;

    /**
     * druid 数据连接池配置
     */
    private DruidConfig druid;

    /**
     * 从数据源方言
     */
    private Class<? extends Dialect> dialect;

    /**
     * other 数据连接池配置
     */
    private Properties other;

    public ConfigType getConfigType() {
        return configType;
    }

    public HikariConfig getHikari() {
        return hikari;
    }

    public void setHikari(HikariConfig hikari) {
        this.hikari = hikari;
        this.configType = ConfigType.HIKARI;
    }

    public DruidConfig getDruid() {
        return druid;
    }

    public void setDruid(DruidConfig druid) {
        this.druid = druid;
        this.configType = ConfigType.DRUID;
    }

    /**
     * 从数据源方言
     * @param dialect 方言的class
     */
    public void setDialect(Class<? extends Dialect> dialect) {
        this.dialect = dialect;
    }

    public Class<? extends Dialect> getDialect() {
        return dialect;
    }

    public Properties getOther() {
        return other;
    }

    public void setOther(Properties other) {
        this.other = other;
        this.configType = ConfigType.OTHER;
    }
}
